package com.example.qxfw.qxybzz.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.qxybzz.entity.PageBean;
import com.example.qxfw.qxybzz.entity.dto.MessageDto;
import com.example.qxfw.qxybzz.entity.dto.PersonDto;
import com.example.qxfw.qxybzz.service.ProcessService;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/process")
public class ProcessController {

    private final ProcessService processService;


    /**
     * 短信信息
     */
    @GetMapping("/getMessage")
    public SysResult getMessageList(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer pageSize,
                                @RequestBody MessageDto messageDto) {

        PageBean pageBean = processService.getMessageList(page, pageSize, messageDto);
        return SysResult.success(pageBean);
    }

    /**
     * 根据id删除
     */
    @DeleteMapping("/deleteMessage")
    public SysResult deleteMessage(@RequestParam Integer id) {
        processService.deleteMessage(id);
        return SysResult.success();
    }


    /**
     * 批量删除
     */
    @DeleteMapping("/deleteMessages")
    public SysResult deleteMessages(@RequestBody Integer[] ids) {
        processService.deletePersons(ids);
        return SysResult.success();
    }


    /**
     * 添加信息
     * @param messageDto
     * @return
     */
    @PostMapping("/addMessages")
    public SysResult addMessages(@RequestBody MessageDto messageDto) {
        processService.addMessage(messageDto);
        return SysResult.success();
    }


}
